import request from "/@/utils/request"

export function fetchList(query?: Object) {
  return request({
    url: '/srm/srmAsnH/page',
    method: 'get',
    params: query
  })
}

export function addObj(obj?: Object) {
  return request({
    url: '/srm/srmAsnH',
    method: 'post',
    data: obj
  })
}

export function getObj(id?: string) {
  return request({
    url: '/srm/srmAsnH/' + id,
    method: 'get'
  })
}

export function delObjs(ids?: Object) {
  return request({
    url: '/srm/srmAsnH',
    method: 'delete',
    data: ids
  })
}

export function putObj(obj?: Object) {
  return request({
    url: '/srm/srmAsnH',
    method: 'put',
    data: obj
  })
}

export function allocationDetails(obj?: Object) {
  return request({
    url: 'srm/srmAsnD/allocationDetails',
    method: 'get',
    params: obj
  })
}

export function getPage(query?: Object) {
  return request({
    url: '/srm/srmAsnD/page',
    method: 'get',
    params: query
  })
}

//发布送货单
export function releaseAsnOrder(ids?: Object) {
  return request({
    url: '/srm/srmAsnH/releaseAsnOrder',
    method: 'post',
    data: ids
  })
}

//取消发布送货单
export function unReleaseAsnOrder(ids?: Object) {
  return request({
    url: '/srm/srmAsnH/unReleaseAsnOrder',
    method: 'post',
    data: ids
  })
}

//删除送货单
export function cancelAsnOrder(ids?: Object) {
  return request({
    url: '/srm/srmAsnH/cancelAsnOrder',
    method: 'post',
    data: ids
  })
}

//根据送货单明细查询明细码表
export function selectByAsnDId(obj:any) {
  if (!obj.id) {
    return Promise.resolve(null);
  }
  return request({
    url: 'srm/srmAsnBarcode/selectByAsnDId/'+ obj.id,
    method: 'get',
  })
}

//批量生成送货单二维码
export function insertOrUpdateBatch(obj?: Object) {
  return request({
    url: 'srm/srmAsnBarcode/insertOrUpdateBatch',
    method: 'put',
    data: obj
  })
}

/**
 * 插入条码
 * @param query
 */
export function InsertBarcodeBySrmBarcode(query?: Object) {
  return request({
    url: 'wms/commonBarcode/InsertBarcodeBySrmBarcode',
    method: 'post',
    data: query
  })
}

